//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------
/*
*/

package uxgenes.core;

import android.util.Log;
import android.widget.Toast;


//
// Logger
//

public final class Logger
{
	private	static final String		TAG			= "UXGEN-ES ";
	public 	static final boolean	DEBUG_MODE	= true;
	private static final boolean	SHOW_TOAST	= true;
	
	
	// OnCatchException
	public static final void OnCatchException (String tag, Exception e)
	{
		if ( !DEBUG_MODE ) return;
		Log.e( TAG + tag, "Catched exception: " + e.toString() );
		e.printStackTrace();
		_ShowToast( tag, "Exception: " + e.toString() );
	}
	
	public static final void OnCatchException (Exception e)
	{
		OnCatchException( "", e );
	}

	
	// E
	public static final void E (String tag, String msg)
	{
		if ( !DEBUG_MODE ) return;
		Log.e( TAG + tag, msg );
		_ShowToast( tag, msg );
	}

	public static final void E (String msg)
	{
		E( "", msg );
	}
	
	
	// W
	public static final void W (String tag, String msg)
	{
		if ( !DEBUG_MODE ) return;
		Log.w( TAG + tag, msg );
		_ShowToast( tag, msg );
	}
	
	public static final void W (String msg)
	{
		W( "", msg );
	}
	
	
	// I
	public static final void I (String tag, String msg)
	{
		if ( !DEBUG_MODE ) return;
		Log.i( TAG + tag, msg );
	}

	public static final void I (String msg)
	{
		I( "", msg );
	}
	

	// _ShowToast
	private static final void _ShowToast (String tag, String msg)
	{
		if ( !SHOW_TOAST ) return;
		Toast.makeText( UXApplication.GetContext(), tag + ": " + msg, Toast.LENGTH_LONG ).show();
	}
}
